package com.ruoyi.shoppingcar.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.shoppingcar.mapper.ShoppingcarMapper;
import com.ruoyi.shoppingcar.domain.Shoppingcar;
import com.ruoyi.shoppingcar.service.IShoppingcarService;

/**
 * 购物车Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-07-22
 */
@Service
public class ShoppingcarServiceImpl implements IShoppingcarService
{
    @Autowired
    private ShoppingcarMapper shoppingcarMapper;

    /**
     * 查询购物车
     *
     * @param id 购物车主键
     * @return 购物车
     */
    @Override
    public Shoppingcar selectShoppingcarById(Long id)
    {
        return shoppingcarMapper.selectShoppingcarById(id);
    }

    /**
     * 查询购物车列表
     *
     * @param shoppingcar 购物车
     * @return 购物车
     */
    @Override
    public List<Shoppingcar> selectShoppingcarList(Shoppingcar shoppingcar)
    {
        return shoppingcarMapper.selectShoppingcarList(shoppingcar);
    }

    /**
     * 新增购物车
     *
     * @param shoppingcar 购物车
     * @return 结果
     */
    @Override
    public int insertShoppingcar(Shoppingcar shoppingcar)
    {
        return shoppingcarMapper.insertShoppingcar(shoppingcar);
    }

    /**
     * 修改购物车
     *
     * @param shoppingcar 购物车
     * @return 结果
     */
    @Override
    public int updateShoppingcar(Shoppingcar shoppingcar)
    {
        return shoppingcarMapper.updateShoppingcar(shoppingcar);
    }

    /**
     * 批量删除购物车
     *
     * @param ids 需要删除的购物车主键
     * @return 结果
     */
    @Override
    public int deleteShoppingcarByIds(Long[] ids)
    {
        return shoppingcarMapper.deleteShoppingcarByIds(ids);
    }

    /**
     * 删除购物车信息
     *
     * @param id 购物车主键
     * @return 结果
     */
    @Override
    public int deleteShoppingcarById(Long id)
    {
        return shoppingcarMapper.deleteShoppingcarById(id);
    }

    /**
     * 添加商品到购物车
     * @param shoppingcar 购物车
     * @return 结果
     */
    @Override
    public int addDishToCart(Shoppingcar shoppingcar) {
        return shoppingcarMapper.addShoppingcar(shoppingcar);
    }


}
